package com.ss.android.crash.log;

import android.os.Handler;
import android.os.Looper;

import java.io.File;

import inline.CrashDemo;

public final class d extends Thread {
    private Handler a;
    private long b;
    private long c;
    private volatile int d;
    private final c e;
    private volatile long f;
    private Runnable g;

    public d(c arg5) {

        this.a = new Handler(Looper.getMainLooper());
        this.b = 5000;
        this.d = 0;
        this.g = new e(this);
        this.e = arg5;
        this.b = 5000;
        this.c = a();
    }

    private static long a() {
        File v0 = new File("/data/anr/traces.txt");
        long v0_1 = v0.exists() ? v0.lastModified() : 0;
        return v0_1;
    }

    static int a(d arg1) {
        return arg1.d;
    }

    static int a(d arg0, int arg1) {
        arg0.d = arg1;
        return arg1;
    }

    public final void run() {
        int v2;
        int v0_1;
        long v10 = 0;
        super.run();
        this.setName("ANR_FILE_MODIFY");
        while (!this.isInterrupted()) {
            int v5 = this.d;
            this.a.post(this.g);
            CrashDemo.a(this.b);
            if (v5 != this.d) {
                continue;
            }

            File v0 = new File("/data/anr/traces.txt");
            v0_1 = !v0.exists() || !v0.canRead() ? 0 : 1;
            if (v0_1 != 0) {
                v0_1 = 0;
                v2 = 0;
                while (true) {
                    if (v5 != this.d) {
                        break;
                    }

                    long v6 = a();
                    int v3 = v6 == v10 || this.c == v10 || this.c == v6 ? 0 : 1;
                    if (v3 != 0) {
                        ++v0_1;
                        this.c = a();
                        this.e.a(200, "/data/anr/traces.txt");
                        if (v0_1 >= 3) {
                            break;
                        }
                    } else {
                        CrashDemo.a(500);
                    }

                    v3 = v2 + 1;
                    if (v2 > 40) {
                        break;
                    }

                    v2 = v3;
                }
            }
            long v2_1 = System.currentTimeMillis();
            if (v2_1 - this.f > 20000) {
                this.e.a(100, null);
            }

            this.f = v2_1;
        }
        return;

    }
}

